Skip to content

Fix {image/video/audio}_token_ids in ProcessorMixin#46500

Merged
hmellor merged 1 commit into
huggingface:mainfrom
hmellor:fix-processor-mixin
Jun 8, 2026
Merged

Fix {image/video/audio}_token_ids in ProcessorMixin#46500
hmellor merged 1 commit into
huggingface:mainfrom
hmellor:fix-processor-mixin

Conversation

@hmellor

@hmellor hmellor commented Jun 8, 2026

Copy link
Copy Markdown
Member

#45493 converted these attributes to properties. This breaks custom models which set {image/video/audio}_token_ids directly because:

  • There is no setter, so these properties are read-only
  • The getter will only ever read from image_token_id

This PR maintains BC by:

  • Adding a setter for these properties
  • Updating the getter to to first check if {image/video/audio}_token_ids has been explicitly set

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

CI Dashboard: View test results in Grafana

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just to be safe let's check that these private properties aren't getting serialized in a dict when we save

@hmellor

hmellor commented Jun 8, 2026

Copy link
Copy Markdown
Member Author
>>> from transformers import ProcessorMixin
>>> processor = ProcessorMixin()
>>> processor.image_token_ids = [0, 1, 2]
>>> processor.image_token_ids
[0, 1, 2]
>>> processor.to_dict()
{'processor_class': 'ProcessorMixin'}

@hmellor hmellor added this pull request to the merge queue Jun 8, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 8, 2026
@hmellor hmellor added the for patch Tag issues / labels that should be included in the next patch label Jun 8, 2026
@hmellor hmellor added this pull request to the merge queue Jun 8, 2026
Merged via the queue into huggingface:main with commit d6a82ba Jun 8, 2026
120 checks passed
@hmellor hmellor deleted the fix-processor-mixin branch June 8, 2026 18:05
khushali9 pushed a commit to khushali9/transformers that referenced this pull request Jun 8, 2026
…46500)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
louzongzhi pushed a commit to louzongzhi/transformers that referenced this pull request Jun 10, 2026
…46500)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
louzongzhi pushed a commit to louzongzhi/transformers that referenced this pull request Jun 10, 2026
…46500)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
ArthurZucker pushed a commit that referenced this pull request Jun 11, 2026
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants